import temperature
from settings import settings
import metric
from logger import log
import argparse
import threading
from version import run_server

if __name__ == "__main__":
    try:
        parser = argparse.ArgumentParser()
        parser.add_argument('--listen_port', type=int, help='Port to listen on for http server')
        args = parser.parse_args()

        if args.listen_port:
            server_thread = threading.Thread(target=run_server, args=(args.listen_port,))
            server_thread.daemon = True
            server_thread.start()

        settings.init()
        metric.init()
        temperature.main()
    except Exception as e:
        log.exception(f"temperature main error: {e}")
